import 'package:app_30/res/colors.dart';
import 'package:app_30/widgets/my_app_bar.dart';
import 'package:app_30/widgets/my_scroll_view.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

import '../my_text_field.dart';

class TxPage extends StatefulWidget {
  const TxPage({Key? key}) : super(key: key);

  @override
  State<TxPage> createState() => _TxPageState();
}

class _TxPageState extends State<TxPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: MyAppBar(
          isBack: false,
          centerTitle: '提现',
        ),
        body: MyScrollView(children: [
          Container(
              decoration: BoxDecoration(
                color: Colors.white10,
              ),
              child: Column(
                children: [
                  Container(
                    padding: EdgeInsets.all(10),
                    decoration: BoxDecoration(color: Colors.white),
                    child: Column(
                      children: [
                        Row(
                          children: [
                            Text("支付宝账户",
                                style: TextStyle(
                                    fontSize: 15.5, color: Colors.grey)),
                            SizedBox(
                              width: 8,
                            ),
                            Flexible(
                              child: TextField(
                                decoration:
                                    InputDecoration.collapsed(hintText: "请输入"),
                              ),
                            )
                          ],
                        ),
                        buildPadding(),
                        Row(
                          children: [
                            Text("收款人姓名",
                                style: TextStyle(
                                    fontSize: 15.5, color: Colors.grey)),
                            SizedBox(
                              width: 8,
                            ),
                            Flexible(
                              child: TextField(
                                decoration:
                                    InputDecoration.collapsed(hintText: "请输入"),
                              ),
                            )
                          ],
                        ),
                        buildPadding(),
                        Row(
                          children: [
                            Text("提现金额    ",
                                style: TextStyle(
                                    fontSize: 15.5, color: Colors.grey)),
                            SizedBox(
                              width: 8,
                            ),
                            Flexible(
                              child: TextField(
                                decoration:
                                    InputDecoration.collapsed(hintText: "请输入"),
                              ),
                            )
                          ],
                        ),
                        buildPadding(),
                        Row(
                          children: [
                            Text("可提现金额",
                                style: TextStyle(
                                    fontSize: 15.5, color: Colors.grey)),
                            SizedBox(
                              width: 8,
                            ),
                            Expanded(
                              child: TextField(
                                decoration:
                                    InputDecoration.collapsed(hintText: "请输入"),
                              ),
                            ),
                            SizedBox(
                              height: 25,
                              child: TextButton(
                                child: Text(
                                  "刷新",
                                  style: TextStyle(
                                      fontSize: 14, color: Colours.app_main),
                                ),
                                //添加一个点击事件
                                onPressed: () {},
                                //设置按钮是否自动获取焦点
                                autofocus: true,
                                style: ButtonStyle(
                                  padding: MaterialStateProperty.all(
                                      EdgeInsets.zero),
                                ),
                              ),
                            )
                          ],
                        ),
                        buildPadding(),
                        Row(
                          mainAxisSize: MainAxisSize.max,
                          children: [
                            Text(
                              "1.手动阀手动阀技术的封建士大夫\n 1.手动阀手动阀\n1.手动阀手动阀\n1.手动阀手动阀\n1.手动阀手动阀\n1.手动阀手动阀\n1.手动阀手动阀\n",
                              textAlign: TextAlign.left,
                              style:
                                  TextStyle(fontSize: 14, color: Colors.grey),
                            )
                          ],
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(top: 40, left: 20, right: 20),
                    child: SizedBox(
                      width: double.infinity,
                      height: 40,
                      child: TextButton(
                        child: Text("确 认 提 现"),
                        //添加一个点击事件
                        onPressed: () {},
                        //设置按钮是否自动获取焦点
                        autofocus: true,
                        //定义一下文本样式
                        style: buildButtonStyle(),
                      ),
                    ),
                  )
                ],
              )),
        ]));
  }

  Padding buildPadding() {
    return Padding(
      padding: EdgeInsets.only(top: 10, bottom: 10),
      child: SizedBox(
        width: double.infinity,
        height: 1,
        child: Container(
          color: Colors.grey,
        ),
      ),
    );
  }

  ButtonStyle buildButtonStyle() {
    return ButtonStyle(
      //定义文本的样式 这里设置的颜色是不起作用的
      textStyle: MaterialStateProperty.all(
          TextStyle(fontSize: 15, color: Colours.app_main)),
      //设置按钮上字体与图标的颜色
      //foregroundColor: MaterialStateProperty.all(Colors.deepPurple),
      //更优美的方式来设置
      foregroundColor: MaterialStateProperty.resolveWith(
        (states) {
          if (states.contains(MaterialState.focused) &&
              !states.contains(MaterialState.pressed)) {
            //获取焦点时的颜色
            return Colors.white;
          } else if (states.contains(MaterialState.pressed)) {
            //按下时的颜色
            return Colors.white70;
          }
          //默认状态使用灰色
          return Colors.white;
        },
      ),
      //背景颜色
      backgroundColor: MaterialStateProperty.resolveWith((states) {
        //设置按下时的背景颜色
        if (states.contains(MaterialState.pressed)) {
          return Colours.dark_app_main;
        }
        //默认不使用背景颜色
        return Colours.app_main;
      }),
      //设置水波纹颜色
      overlayColor: MaterialStateProperty.all(Colours.app_main),
      //设置阴影  不适用于这里的TextButton
      elevation: MaterialStateProperty.all(0),
      //设置按钮内边距
      padding: MaterialStateProperty.all(EdgeInsets.all(10)),
      //设置按钮的大小
      // minimumSize: MaterialStateProperty.all(Size(double.infinity,40)),
      //设置边框
      // side: MaterialStateProperty.all(BorderSide(color: Colors.grey, width: 1)),
      //外边框装饰 会覆盖 side 配置的样式
      // shape: MaterialStateProperty.all(StadiumBorder()),
    );
  }
}
